home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / rotating / rotating.sty < prev    next >
Text File  |  1994-04-17  |  12KB  |  433 lines

  1. %% 
  2. %% This is file `rotating.sty', generated 
  3. %% on <1994/2/9> with the docstrip utility (2.2e).
  4. %% 
  5. %% The original source files were:
  6. %% 
  7. %% rotating.doc 
  8. %% S Rahtz 
  9. %% spqr@minster.york.ac.uk 
  10. %% 
  11. %% 10 July 1993 
  12. %% 
  13. \def\styleoption{rotating.sty}
  14. \def\fileversion{v1.9}
  15. \def\filedate{93/11/1}
  16. \immediate\write\sixt@@n{Style option: \styleoption,
  17. \fileversion\space <\filedate> (SPQR / LMB)}
  18. \def\rot@start{}
  19. \def\rot@end{}
  20. \def\rotdriver#1{%
  21.   \bgroup\edef\next{\def\noexpand\tempa{#1}}%
  22.     \uppercase\expandafter{\next}%
  23.     \def\LN{DVITOLN03}%
  24.     \def\DVItoPS{DVITOPS}%
  25.     \def\DVIPS{DVIPS}%
  26.     \def\emTeX{EMTEX}%
  27.     \def\Textures{TEXTURES}%
  28.     \def\Pubps{PUBPS}%
  29.     \global\chardef\rot@driversetup=0
  30.     \ifx\tempa\LN
  31.         \global\chardef\rot@driversetup=0\fi
  32.     \ifx\tempa\DVItoPS
  33.         \global\chardef\rot@driversetup=1\fi
  34.     \ifx\tempa\DVIPS
  35.         \global\chardef\rot@driversetup=2\fi
  36.     \ifx\tempa\emTeX
  37.         \global\chardef\rot@driversetup=3\fi
  38.     \ifx\tempa\Textures
  39.         \global\chardef\rot@driversetup=4\fi
  40.     \ifx\tempa\Pubps
  41.        \global\chardef\rot@driversetup=5\fi
  42.   \egroup
  43. \ifcase\rot@driversetup
  44. \typeout{WARNING! ****
  45.  no specials for LN03  rotation}
  46. \or
  47. \rot@count=1
  48. \def\rot@start{\special{dvitops: origin
  49.     rot\the\rot@count}%
  50. \special{dvitops: begin rot\the\rot@count}}%
  51. \def\rot@end{\special{dvitops: end}%
  52. \special{dvitops: rotate rot\the\rot@count \space
  53.     \the\rot@angle}%
  54. \global\advance\rot@count by1}%
  55. \or
  56. \def\rot@start{\special{ps:gsave currentpoint
  57. currentpoint translate \the\rot@angle\space
  58. rotate  neg exch neg exch translate}}%
  59. \def\rot@end{\special{ps:currentpoint
  60. grestore moveto}}%
  61. \or % case 3, emTeX
  62. \typeout{WARNING! ***
  63.  emTeX does no rotation at this time}
  64. \or
  65. \typeout{Textures rotation}
  66. \def\rot@start{\special{postscript
  67.   0 0 transform                 % Get current location in device
  68.                                 % coordinates.
  69.   grestore                      % Undoes TeXtures gsave.
  70.   matrix currentmatrix          % Save current transform on stack for use
  71.                                 % by \@unrotate.
  72.   3 1 roll                      % Put transform at back of current location.
  73.   itransform                    % Current location in TeXtures coords
  74.   dup 3 -1 roll                 % Duplicate the location; x y ==> x y x y
  75.   dup 4 1 roll exch
  76.   translate                     % Translate origin to current location
  77.  % 1 -1 scale                    % Flip y coordinate
  78.   \the\rot@angle\space rotate   % Rotate by \@rotation
  79.  % 1 -1 scale                    % Unflip y coordinate
  80.   neg exch neg exch translate   % Translate origin back
  81.   gsave}}                       % To match grestore
  82. \def\rot@end{\special{postscript
  83.   grestore                      % Undoes TeXtures gsave
  84.   setmatrix                     % Set current transform to value saved on
  85.                                 % stack.  (Hopefully, it's still there.)
  86.   gsave}}                       % To match grestore
  87. \typeout{Process .DVI file with Pubps}
  88.   \def\rot@start{\special{ps:: gsave currentpoint
  89.   currentpoint translate \the\rot@angle\space
  90.   neg rotate  neg exch neg exch translate}}%
  91.   \def\rot@end{\special{ps:: currentpoint
  92.   grestore moveto}}%
  93. \else
  94. \typeout{WARNING! ***
  95.  unknown  driver - no rotation}
  96. \fi
  97. }
  98. \newsavebox{\rot@box}%
  99. \newsavebox{\rot@tempbox}%
  100. \newdimen\rot@temp
  101. \newdimen\rot@width
  102. \newdimen\rot@height
  103. \newdimen\rot@depth
  104. \newdimen\rot@right
  105. \newdimen\rot@left
  106. \newcount\rot@angle
  107. \newcount\rot@count
  108. \newcount\rot@circle
  109. \def\sideways{\setbox\rot@box\hbox\bgroup\ignorespaces}
  110. \def\endsideways{\unskip\egroup%
  111. \rot@angle-90
  112. \rot@width\ht\rot@box
  113. \advance\rot@width by\dp\rot@box
  114. \rot@height\wd\rot@box
  115. \wd\rot@box\z@
  116. \dp\rot@box\z@
  117. \ht\rot@box\z@
  118. \rule{\rot@width}{\z@}%
  119. \rlap{\rule{\z@}{\rot@height}}%
  120. \rot@start\usebox{\rot@box}\rot@end%
  121. }
  122. \def\rotate#1{%
  123. \global\rot@angle=\rot@direction#1\relax
  124. \setbox\rot@box\hbox\bgroup\ignorespaces}
  125. \def\endrotate{\unskip\egroup%
  126. \rot@start%
  127. \dp\rot@box=\z@\wd\rot@box=\z@\ht\rot@box=\z@
  128. \usebox{\rot@box}%
  129. \rot@end%
  130. }%
  131. \def\rotatedirection#1{%
  132.   \def\@tempa{#1}\def\@tempb{clockwise}%
  133.   \edef\rot@direction{\ifx\@tempa\@tempb\else-\fi}}
  134. \rotatedirection{clockwise}
  135. \let\turn=\rotate
  136. \def\endturn{%
  137. \unskip\egroup%
  138. \multiply\rot@angle by-1
  139. \Sine{\rot@angle}%
  140. \let\sineA\sine
  141. \advance\rot@angle by90%
  142. \Sine{\rot@angle}%
  143. \let\sineB\sine
  144. \def\sineC{-\sine}%
  145. \def\cosineA{-\sineC}%
  146. \def\cosineB{-\sineA}%
  147. \let\cosineC\sineA
  148. \advance\rot@angle by-90%
  149. \def\rot@Bx{\rot@temp\cosineA\wd\rot@box
  150.    \advance\rot@temp by -\sineA\ht\rot@box}%
  151. \def\rot@By{\rot@temp\sineA\wd\rot@box
  152.   \advance\rot@temp by \cosineA\ht\rot@box}%
  153. \def\rot@Cx{\rot@temp\cosineB\ht\rot@box}%
  154. \def\rot@Cy{\rot@temp\sineB\ht\rot@box}%
  155. \def\rot@Dx{\rot@temp\cosineC\dp\rot@box}%
  156. \def\rot@Dy{\rot@temp\sineC\dp\rot@box}%
  157. \def\rot@Ex{\rot@temp\cosineC\dp\rot@box
  158.    \advance\rot@temp by -\sineC\wd\rot@box}%
  159. \def\rot@Ey{\rot@temp\sineC\dp\rot@box
  160.    \advance\rot@temp by \cosineC\wd\rot@box}%
  161. \rot@circle\rot@angle
  162. \ifnum\rot@circle<0
  163.      \advance\rot@circle by 360
  164. \fi
  165. \ifnum\rot@circle<90
  166. \rot@By\rot@height\rot@temp
  167. \rot@Ex\rot@right\rot@temp
  168. \rot@Cx\rot@left\rot@temp
  169. \rot@Dy\rot@depth\rot@temp
  170. \else
  171.      \ifnum\rot@circle<180
  172.        \rot@Ey\rot@height\rot@temp
  173.        \rot@Dx\rot@right\rot@temp
  174.        \rot@Bx\rot@left\rot@temp
  175.        \rot@Cy\rot@depth\rot@temp
  176.      \else
  177.             \ifnum\rot@circle<270
  178.            \rot@Dy\rot@height\rot@temp
  179.            \rot@Cx\rot@right\rot@temp
  180.            \rot@Ex\rot@left\rot@temp
  181.            \rot@By\rot@depth\rot@temp
  182.             \else
  183.            \rot@Cy\rot@height\rot@temp
  184.            \rot@Bx\rot@right\rot@temp
  185.            \rot@Dx\rot@left\rot@temp
  186.            \rot@Ey\rot@depth\rot@temp
  187.           \fi
  188.      \fi
  189. \fi
  190. \multiply\rot@angle by-1
  191. \wd\rot@box=\z@\ht\rot@box=\z@\dp\rot@box=\z@
  192. \ifdim\rot@left<\z@
  193.      \rule{-\rot@left}{\z@}%
  194. \fi
  195. \ifdim\rot@height>\z@
  196.      \rlap{\rule{\z@}{\rot@height}}%
  197. \fi
  198. \ifdim\rot@depth<\z@
  199.      \rlap{\rule[\rot@depth]{\z@}{-\rot@depth}}%
  200. \fi
  201. \rot@start\usebox{\rot@box}\rot@end%
  202. \ifdim\rot@right>\z@
  203.       \rule{\rot@right}{\z@}%
  204. \fi
  205. }%
  206. \def\@rotfloat#1{\@ifnextchar[{\@xrotfloat{#1}}{%
  207. \edef\@tempa{\noexpand\@xrotfloat{#1}[\csname fps@#1\endcsname]}\@tempa}}
  208. \def\@xrotfloat#1[#2]{\ifhmode \@bsphack\@floatpenalty -\@Mii\else
  209.    \@floatpenalty-\@Miii\fi\def\@captype{#1}\ifinner
  210.       \@parmoderr\@floatpenalty\z@
  211.     \else\@next\@currbox\@freelist{\@tempcnta\csname ftype@#1\endcsname
  212.        \multiply\@tempcnta\@xxxii\advance\@tempcnta\sixt@@n
  213.        \@tfor \@tempa :=#2\do
  214.                         {\if\@tempa h\advance\@tempcnta \@ne\fi
  215.                          \if\@tempa t\advance\@tempcnta \tw@\fi
  216.                          \if\@tempa b\advance\@tempcnta 4\relax\fi
  217.                          \if\@tempa p\advance\@tempcnta 8\relax\fi
  218.          }\global\count\@currbox\@tempcnta}\@fltovf\fi
  219.     \global\setbox\@currbox\vbox\bgroup
  220.   \hsize\textheight \@parboxrestore
  221. }
  222. \def\page@R{R}
  223. \newcommand{\rotfloatpage}{R}
  224. \def\end@rotfloat{\par\vskip\z@\egroup%
  225.    \ifnum\@floatpenalty <\z@
  226.     \global\setbox\rot@tempbox\box\@currbox
  227. \message{Adding sideways figure on }%
  228.    \global\setbox\@currbox\vbox to \wd\rot@tempbox{%
  229.    \ifx\rotfloatpage\page@R
  230. \message{right hand page }%
  231.     \vfill\centerline{%
  232.        \hbox to \ht\rot@tempbox{\hfill
  233.           \begin{rotate}{-90}\box\rot@tempbox\end{rotate}%
  234.             }%
  235.     }%
  236.    \else
  237. \message{left hand page }%
  238.     \centerline{%
  239.        \hbox to \ht\rot@tempbox{%
  240.                \begin{rotate}{90}\box\rot@tempbox\end{rotate}%
  241.                   \hfill}%
  242.                }\vfill
  243.    \fi
  244.       }%
  245.      \@cons\@currlist\@currbox
  246.      \ifdim \ht\@currbox >\textheight
  247.         \@warning{Float larger than \string\textheight}%
  248.         \ht\@currbox\textheight \fi
  249.      \ifnum\@floatpenalty <-\@Mii
  250.         \penalty -\@Miv
  251.         \@tempdima\prevdepth
  252.         \vbox{}%
  253.         \prevdepth \@tempdima
  254.         \penalty\@floatpenalty
  255.       \else \vadjust{\penalty -\@Miv
  256.       \vbox{}\penalty\@floatpenalty}\@esphack
  257.      \fi\fi}
  258. \def\sidewaysfigure{\let\make@caption\make@rcaption
  259. \@rotfloat{figure}}
  260. \let\endsidewaysfigure\end@rotfloat
  261. \def\sidewaystable{\let\make@caption\make@rcaption
  262. \@rotfloat{table}}
  263. \let\endsidewaystable\end@rotfloat
  264. \long\def\@makercaption#1#2{%
  265.    \vskip 10\p@
  266.    \setbox\@tempboxa\hbox{#1: #2}%
  267.    \ifdim \wd\@tempboxa >\vsize
  268.        #1: #2\par
  269.      \else
  270.        \hbox to\vsize{\hfil\box\@tempboxa\hfil}%
  271.    \fi}%
  272. \def\rotcaption{\refstepcounter\@captype\@dblarg{\@rotcaption\@captype}}
  273. \long\def\@rotcaption#1[#2]#3{%
  274. \addcontentsline{\csname ext@#1\endcsname}{#1}{%
  275.  \protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  276.   \par
  277.   \begingroup
  278.     \@parboxrestore
  279.     \normalsize
  280.     \@makerotcaption{\csname fnum@#1\endcsname}{#3}%
  281.   \endgroup}
  282. \long\def\@makerotcaption#1#2{%
  283.  \setbox\@tempboxa\hbox{#1: #2}%
  284.  \ifdim \wd\@tempboxa > .8\vsize
  285.     \begin{rotate}{-90}%
  286.     \begin{minipage}[b]{.8\textheight}#1 #2\end{minipage}%
  287.     \end{rotate}\par
  288.  \else%
  289.     \mbox{\begin{rotate}{-90}\box\@tempboxa\end{rotate}}%
  290.  \fi
  291.  \hspace{12pt}%
  292. }
  293.  
  294. \chardef\letter = 11
  295. \chardef\other = 12
  296. \newif\ifdebug
  297. \newif\ifc@mpute
  298. \c@mputetrue
  299. \let\then =\relax
  300. \def\r@dian{pt }%
  301. \let\r@dians =\r@dian
  302. \let\dimensionless@nit =\r@dian
  303. \let\dimensionless@nits =\dimensionless@nit
  304. \def\internal@nit{sp }%
  305. \let\internal@nits =\internal@nit
  306. \newif\ifstillc@nverging
  307. \def\Mess@ge #1{\ifdebug\then\message {#1}\fi}%
  308. {%
  309. \catcode `\@ =\letter
  310. \gdef\nodimen {\expandafter\n@dimen\the\dimen}%
  311. \gdef\term #1 #2 #3%
  312. {\edef\t@ {\the #1}%
  313. \edef\t@@ {\expandafter\n@dimen\the #2\r@dian}%
  314. \t@rm {\t@} {\t@@} {#3}%
  315. }%
  316. \gdef\t@rm #1 #2 #3%
  317. {{%
  318. \count 0 = 0
  319. \dimen 0 = 1\dimensionless@nit
  320. \dimen 2 = #2\relax
  321. \Mess@ge {Calculating term #1 of\nodimen 2}%
  322. \loop
  323. \ifnum\count 0 < #1
  324. \then\advance\count 0 by 1
  325. \Mess@ge {Iteration\the\count 0\space}%
  326. \Multiply\dimen 0 by {\dimen 2}%
  327. \Mess@ge {After multiplication, term =\nodimen 0}%
  328. \Divide\dimen 0 by {\count 0}%
  329. \Mess@ge {After division, term =\nodimen 0}%
  330. \repeat
  331. \Mess@ge {Final value for term #1 of
  332. \nodimen 2\space is\nodimen 0}%
  333. \xdef\Term {#3 =\nodimen 0\r@dians}%
  334. \aftergroup\Term
  335. }}%
  336. \catcode `\p =\other
  337. \catcode `\t =\other
  338. \gdef\n@dimen #1pt{#1}%
  339. }%
  340. \def\Divide #1by #2{\divide #1 by #2}%
  341. \def\Multiply #1by #2%
  342. {{%
  343. \count 0 = #1\relax
  344. \count 2 = #2\relax
  345. \count 4 = 65536
  346. \Mess@ge {Before scaling, count 0 =\the\count 0\space and
  347. count 2 =\the\count 2}%
  348. \ifnum\count 0 > 32767%
  349. \then\divide\count 0 by 4
  350. \divide\count 4 by 4
  351. \else\ifnum\count 0 < -32767
  352. \then\divide\count 0 by 4
  353. \divide\count 4 by 4
  354. \else
  355. \fi
  356. \fi
  357. \ifnum\count 2 > 32767%
  358. \then\divide\count 2 by 4
  359. \divide\count 4 by 4
  360. \else\ifnum\count 2 < -32767
  361. \then\divide\count 2 by 4
  362. \divide\count 4 by 4
  363. \else
  364. \fi
  365. \fi
  366. \multiply\count 0 by\count 2
  367. \divide\count 0 by\count 4
  368. \xdef\product {#1 =\the\count 0\internal@nits}%
  369. \aftergroup\product
  370. }}%
  371. \def\r@duce{\ifdim\dimen0 > 90\r@dian\then%
  372. \multiply\dimen0 by -1
  373. \advance\dimen0 by 180\r@dian
  374. \r@duce
  375. \else\ifdim\dimen0 < -90\r@dian\then%
  376. \advance\dimen0 by 360\r@dian
  377. \r@duce
  378. \fi
  379. \fi}%
  380. \def\Sine#1%
  381. {{%
  382.        \dimen 0 = #1\r@dian
  383.        \r@duce
  384.        \ifdim\dimen0 = -90\r@dian\then
  385.               \dimen4 = -1\r@dian
  386.               \c@mputefalse
  387.        \fi
  388.        \ifdim\dimen0 = 90\r@dian\then
  389.               \dimen4 = 1\r@dian
  390.               \c@mputefalse
  391.        \fi
  392.        \ifdim\dimen0 = 0\r@dian\then
  393.        \dimen4 = 0\r@dian
  394.        \c@mputefalse
  395. \fi
  396. \ifc@mpute\then
  397. \divide\dimen0 by 180
  398. \dimen0=3.141592654\dimen0
  399. \dimen 2 = 3.1415926535897963\r@dian%
  400. \divide\dimen 2 by 2%
  401. \Mess@ge {Sin: calculating Sin of\nodimen 0}%
  402. \count 0 = 1%
  403. \dimen 2 = 1\r@dian%
  404. \dimen 4 = 0\r@dian%
  405. \loop
  406. \ifnum\dimen 2 = 0%
  407. \then\stillc@nvergingfalse
  408. \else\stillc@nvergingtrue
  409. \fi
  410. \ifstillc@nverging%
  411. \then\term {\count 0} {\dimen 0} {\dimen 2}%
  412. \advance\count 0 by 2
  413. \count 2 =\count 0
  414. \divide\count 2 by 2
  415. \ifodd\count 2%
  416. \then\advance\dimen 4 by\dimen 2
  417. \else\advance\dimen 4 by -\dimen 2
  418. \fi
  419. \repeat
  420. \fi
  421. \xdef\sine {\nodimen 4}%
  422. }}%
  423. \def\Cosine#1{\ifx\sine\UnDefined\edef\Savesine{\relax}\else
  424. \edef\Savesine{\sine}\fi
  425. {\dimen0=#1\r@dian\advance\dimen0 by 90\r@dian
  426. \Sine{\nodimen 0}%
  427. \xdef\cosine{\sine}%
  428. \xdef\sine{\Savesine}}}
  429. \rotdriver{dvips}
  430. \endinput
  431. %% 
  432. %% End of file `rotating.sty'.
  433.